package com.download.backstage.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.download.backstage.entity.ThirdAccount;
import com.download.web.entity.SysNavBar;
import com.download.web.entity.SysThirdAccount;
import com.download.web.entity.model.Page;
import com.download.web.entity.model.Result;
import com.download.web.service.ISysNavBarService;
import com.download.web.service.ISysThirdAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description: 第三方登录设置
 * @author: cmy
 * @create: 2019-02-28 11:20
 **/
@RequestMapping("/backstage/thirdAccount")
@RestController
public class ThirdAccountController {

    @Autowired
    private ISysThirdAccountService thirdAccountService;


    /**
     * 文章类型查询
     * @return
     */
    @RequestMapping("/thirdAccountList")
    public Page<ThirdAccount> thirdAccountList(Integer pageIndex,Integer pageSize){
        Page<ThirdAccount> navBarList=thirdAccountService.thirdAccountListPage(pageIndex,pageSize);
        return navBarList;
    }

    /**
     * 新增导航栏菜单
     * @param thirdAccount
     */
    @RequestMapping("/addThirdAccount")
    public Result<Integer> addThirdAccount(@RequestBody SysThirdAccount thirdAccount) {
        return thirdAccountService.addThirdAccount(thirdAccount);
    }

    @RequestMapping("/update")
    public Result updateThirdAccount(@RequestBody SysThirdAccount thirdAccount){
        return thirdAccountService.updateThirdAccount(thirdAccount);
    }

    /**
     * 按id删除第三方登录设置
     * @param id
     */
    @RequestMapping("/delById")
    public void delById(Integer id){
        thirdAccountService.removeById(id);
    }

    @RequestMapping("/findById")
    public SysThirdAccount findById(Integer id){
        return thirdAccountService.getOne(new QueryWrapper<SysThirdAccount>().eq("id",id));
    }

}
